<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
      <template #operationBeforeExtend="{ record }">
        <a-link @click="openPicList(record)"> 拍照部位</a-link>
      </template>
    </ma-crud>

    <pic-list ref="piclist" />
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import lzccVehicle from '@/api/lzcc/lzccVehicle'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'
import PicList from './piclist.vue'

const crudRef = ref()
const piclist = ref()

const openPicList = async (row) => {
  piclist.value.open(row)
}


const options = reactive({
  id: 'flyos_lzcc_vehicle',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: lzccVehicle.getList,
  add: {
    show: true,
    api: lzccVehicle.save,
    auth: ['lzcc:vehicle:save']
  },
  edit: {
    show: true,
    api: lzccVehicle.update,
    auth: ['lzcc:vehicle:update']
  },
  delete: {
    show: true,
    api: lzccVehicle.deletes,
    auth: ['lzcc:vehicle:delete']
  },
  import: {
    show: true,
    url: 'lzcc/vehicle/import',
    templateUrl: 'lzcc/vehicle/downloadTemplate',
    auth: ['lzcc:vehicle:import']
  },
  export: {
    show: true,
    url: 'lzcc/vehicle/export',
    auth: ['lzcc:vehicle:export']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false
  },
  {
    title: "车型名称",
    dataIndex: "name",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入车型名称"
    },
    sortable: {
      sortDirections: [
        "ascend",
        "descend"
      ],
      sorter: true
    }
  },
  {
    title: "用户类型",
    dataIndex: "userType",
    formType: "select",
    search: true,
    commonRules: {
      required: true,
      message: "请输入用户类型"
    },
    sortable: {
      sortDirections: [
        "ascend",
        "descend"
      ],
      sorter: true
    },
    dict: {
      name: "user_type",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
    }
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    sortable: {
      sortDirections: [
        "ascend",
        "descend"
      ],
      sorter: true
    },
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除状态",
    dataIndex: "del_flag",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'lzcc:vehicle' } </script>